﻿Module Module1

    Private Function descuento(ByVal num As Decimal)
        Select Case num
            Case Is < 500
                Return 0.5
            Case 500 To 999
                Return 0.2
            Case 1000 To 15000
                Return 0.1
        End Select
    End Function
   
    Sub Main()
        Dim line, sueldoSr, familSr As String
        Dim result, sueldo, descu, descu1 As Decimal
        Dim famil As Integer

        Console.Title = "Ejercicio select case 3"
        Do
            Console.Write("Precio del cursillo: ")
            line = Console.ReadLine()
        Loop Until IsNumeric(line)
        result = CDec(line)
        Console.Write("Trabajas/Estudias/Paro(T/E/P): ")
        line = Console.ReadLine()
        Select Case line.ToUpper

            Case "T"
                Do

                    Console.Write("Sueldo: ")
                    sueldoSr = Console.ReadLine()
                Loop Until IsNumeric(sueldoSr)
                sueldo = CDec(sueldoSr)
                descu = descuento(sueldo)
            Case "E", "P"
                descu = 0

        End Select
        Do
            Console.Write("Cantidad de familiares matriculados: ")
            familSr = Console.ReadLine()
        Loop Until IsNumeric(familSr)
        famil = CInt(familSr)
        Select Case famil
            Case 0
                descu1 = 0
            Case 1
                descu1 = 0.1
            Case 2
                descu1 = 0.2
            Case Else
                descu1 = 0.3

        End Select
        result = result - (result * descu) - (result * descu1)
        Console.WriteLine("El total a pagar por el curso son:" & result & "euros")
        Console.ReadKey()

    End Sub

End Module
